package com.qf.day11;

import java.util.Iterator;
import java.util.Random;

public class StrIterator implements Iterator<String> {
    private int count = 0; //生成字符个数
    @Override
    public boolean hasNext() {
        return count<10; //10条数据
    }

    @Override
    public String next() {
        Random random = new Random();
        int length = random.nextInt(10)+1;
        StringBuffer buffer = new StringBuffer();
        while (length-- != 0){
            int i = random.nextInt(26)+97;
            buffer.append(Character.toChars(i));
        }
        count++;
        return buffer.toString();
    }

    public static void main(String[] args) {
        StrIterator iterator = new StrIterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
